package com.ziyia.progressbar;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {
    private ProgressBar pb1, pb2;
    private NotificationManager manager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        pb1 = findViewById(R.id.pb1);
        pb2 = findViewById(R.id.pb2);

    }


    /**
     * 显示与隐藏进度条
     * @param view
     */
    public void setProgressBarHidden(View view) {
        if (pb1.getVisibility() == View.GONE) {
            pb1.setVisibility(View.VISIBLE);
        } else {
            pb1.setVisibility(View.GONE);
        }
    }

    /**
     * 设置进度条的进度
     * @param view
     */
    public void setProgressBarValue(View view) {
        int progress = pb2.getProgress();
        // 如果进度值为进度条最大进度
        if (progress == pb2.getMax()) {
            pb2.setProgress(0); // 从0开始
        } else { // 如果进度值不是最大的进度值
            progress += 10; // 每次增加 10
            pb2.setProgress(progress);
        }
    }

}